package file.tobookdata;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.List;

import dao.pojo.Book;

public class FileToBookData {
	
	public List<Book> getBookDataFromFile(String filepath) throws Exception{
		List<Book> bList=new ArrayList<Book>();
		FileInputStream fin=new FileInputStream(new File(filepath));
		ObjectInputStream oIn=new ObjectInputStream(fin);
		bList=(List<Book>)oIn.readObject();		
		return bList;
	}
	
//	public static void main(String[] args) throws Exception {
//		List<Book> bList=new ArrayList<Book>();
//		FileToBookData ftd=new FileToBookData();
//		bList=ftd.getBookDataFromFile("book.data");
//		for (int i = 0; i < bList.size(); i++) {
//			System.out.println(bList.get(i).getId());
//		}
//		
//	}

}
